package sudroid.json;

import java.util.Iterator;

public class JSONML
{
  private static Object parse(XMLTokener paramXMLTokener, boolean paramBoolean, JSONArray paramJSONArray)
    throws JSONException
  {
    Object localObject1 = null;
    JSONObject localJSONObject1 = null;
    JSONArray localJSONArray1 = null;
    boolean bool1 = null;
    while (true)
    {
      Object localObject3 = paramXMLTokener.nextContent();
      Character localCharacter1 = XML.LT;
      label318: Object localObject5;
      if (localObject3 == localCharacter1)
      {
        Object localObject6 = paramXMLTokener.nextToken();
        if ((localObject6 instanceof Character))
        {
          Character localCharacter2 = XML.SLASH;
          if (localObject6 == localCharacter2)
          {
            paramBoolean = paramXMLTokener.nextToken();
            if (!(paramBoolean instanceof String))
            {
              String str1 = "Expected a closing name instead of '" + paramBoolean + "'.";
              throw new JSONException(str1);
            }
            Object localObject7 = paramXMLTokener.nextToken();
            Character localCharacter3 = XML.GT;
            if (localObject7 != localCharacter3)
              throw paramXMLTokener.syntaxError("Misshaped close tag");
            Object localObject8 = localObject1;
            JSONObject localJSONObject2 = localJSONObject1;
            boolean bool2 = bool1;
            bool1 = paramBoolean;
            JSONArray localJSONArray2 = localJSONArray1;
          }
        }
        while (true)
        {
          return bool1;
          Character localCharacter4 = XML.BANG;
          if (localObject6 == localCharacter4)
          {
            int i = paramXMLTokener.next();
            if (i == 45)
            {
              if (paramXMLTokener.next() == 45)
                boolean bool3 = paramXMLTokener.skipPast("-->");
              paramXMLTokener.back();
              break;
            }
            if (i == 91)
            {
              if ((paramXMLTokener.nextToken().equals("CDATA")) && (paramXMLTokener.next() == 91))
              {
                if (paramJSONArray == null)
                  break;
                String str2 = paramXMLTokener.nextCDATA();
                JSONArray localJSONArray3 = paramJSONArray.put(str2);
                break;
              }
              throw paramXMLTokener.syntaxError("Expected 'CDATA['");
            }
            Object localObject4 = null;
            while (true)
            {
              localObject6 = paramXMLTokener.nextMeta();
              if (localObject6 == null)
                throw paramXMLTokener.syntaxError("Missing '>' after '<!'.");
              Character localCharacter5 = XML.LT;
              int j;
              if (localObject6 == localCharacter5)
                j = localObject4 + 1;
              while (true)
              {
                if (j > 0)
                  break label318;
                break;
                Character localCharacter6 = XML.GT;
                if (localObject6 != localCharacter6)
                  continue;
                j = j + -1;
              }
            }
          }
          Character localCharacter7 = XML.QUEST;
          if (localObject6 == localCharacter7)
          {
            boolean bool4 = paramXMLTokener.skipPast("?>");
            break;
          }
          throw paramXMLTokener.syntaxError("Misshaped tag");
          if (!(localObject6 instanceof String))
          {
            String str3 = "Bad tagName '" + localObject6 + "'.";
            throw paramXMLTokener.syntaxError(str3);
          }
          localObject1 = (String)localObject6;
          localJSONArray1 = new JSONArray();
          localJSONObject1 = new JSONObject();
          if (paramBoolean)
          {
            JSONArray localJSONArray4 = localJSONArray1.put(localObject1);
            if (paramJSONArray != null)
              JSONArray localJSONArray5 = paramJSONArray.put(localJSONArray1);
            localObject5 = null;
          }
          while (true)
          {
            if (localObject5 == null)
              localObject5 = paramXMLTokener.nextToken();
            if (localObject5 == null)
            {
              throw paramXMLTokener.syntaxError("Misshaped tag");
              JSONObject localJSONObject3 = localJSONObject1.put("tagName", localObject1);
              if (paramJSONArray == null)
                break;
              JSONArray localJSONArray6 = paramJSONArray.put(localJSONObject1);
              break;
            }
            if (!(localObject5 instanceof String))
            {
              if ((paramBoolean) && (localJSONObject1.length() > 0))
                JSONArray localJSONArray7 = localJSONArray1.put(localJSONObject1);
              Character localCharacter8 = XML.SLASH;
              if (localObject5 != localCharacter8)
                break label722;
              Object localObject9 = paramXMLTokener.nextToken();
              Character localCharacter9 = XML.GT;
              if (localObject9 == localCharacter9)
                break label670;
              throw paramXMLTokener.syntaxError("Misshaped tag");
            }
            localObject5 = (String)localObject5;
            if ((!paramBoolean) && ((localObject5 == "tagName") || (localObject5 == "childNode")))
              throw paramXMLTokener.syntaxError("Reserved attribute.");
            localObject6 = paramXMLTokener.nextToken();
            Character localCharacter10 = XML.EQ;
            if (localObject6 == localCharacter10)
            {
              localObject6 = paramXMLTokener.nextToken();
              if (!(localObject6 instanceof String))
                throw paramXMLTokener.syntaxError("Missing value");
              Object localObject10 = JSONObject.stringToValue((String)localObject6);
              JSONObject localJSONObject4 = localJSONObject1.accumulate((String)localObject5, localObject10);
              localObject5 = null;
              continue;
            }
            JSONObject localJSONObject5 = localJSONObject1.accumulate((String)localObject5, "");
            localObject5 = localObject6;
          }
          label670: if (paramJSONArray != null)
            break;
          if (paramBoolean)
          {
            Object localObject11 = localObject1;
            JSONObject localJSONObject6 = localJSONObject1;
            JSONArray localJSONArray8 = localJSONArray1;
            boolean bool5 = bool1;
            localObject2 = localJSONArray1;
            continue;
          }
          Object localObject12 = localObject1;
          JSONObject localJSONObject7 = localJSONObject1;
          JSONArray localJSONArray9 = localJSONArray1;
          Object localObject13 = localObject2;
          localObject2 = localJSONObject1;
          continue;
          label722: Character localCharacter11 = XML.GT;
          if (localObject5 != localCharacter11)
            throw paramXMLTokener.syntaxError("Misshaped tag");
          localObject5 = (String)parse(paramXMLTokener, paramBoolean, localJSONArray1);
          if (localObject5 == null)
            break label930;
          if (!((String)localObject5).equals(localObject1))
          {
            String str4 = "Mismatched '" + (String)localObject1 + "' and '" + (String)localObject5 + "'";
            throw paramXMLTokener.syntaxError(str4);
          }
          localObject2 = null;
          if ((!paramBoolean) && (localJSONArray1.length() > 0))
            JSONObject localJSONObject8 = localJSONObject1.put("childNodes", localJSONArray1);
          if (paramJSONArray != null)
            break label920;
          if (paramBoolean)
          {
            JSONObject localJSONObject9 = localJSONObject1;
            JSONArray localJSONArray10 = localJSONArray1;
            Object localObject14 = localObject5;
            Object localObject15 = localObject2;
            localObject2 = localJSONArray1;
            continue;
          }
          JSONObject localJSONObject10 = localJSONObject1;
          JSONArray localJSONArray11 = localJSONArray1;
          Object localObject16 = localObject5;
          Object localObject17 = localObject2;
          localObject2 = localJSONObject1;
        }
      }
      if (paramJSONArray == null)
        continue;
      if ((localObject5 instanceof String))
        localObject5 = JSONObject.stringToValue((String)localObject5);
      JSONArray localJSONArray12 = paramJSONArray.put(localObject5);
      continue;
      label920: localObject1 = localObject2;
      Object localObject2 = localObject5;
      continue;
      label930: localObject2 = localObject5;
    }
  }

  public static JSONArray toJSONArray(String paramString)
    throws JSONException
  {
    return toJSONArray(new XMLTokener(paramString));
  }

  public static JSONArray toJSONArray(XMLTokener paramXMLTokener)
    throws JSONException
  {
    return (JSONArray)parse(paramXMLTokener, 1, null);
  }

  public static JSONObject toJSONObject(String paramString)
    throws JSONException
  {
    return toJSONObject(new XMLTokener(paramString));
  }

  public static JSONObject toJSONObject(XMLTokener paramXMLTokener)
    throws JSONException
  {
    return (JSONObject)parse(paramXMLTokener, 0, null);
  }

  public static String toString(JSONArray paramJSONArray)
    throws JSONException
  {
    StringBuffer localStringBuffer1 = new StringBuffer();
    String str1 = paramJSONArray.getString(0);
    XML.noSpace(str1);
    String str2 = XML.escape(str1);
    StringBuffer localStringBuffer2 = localStringBuffer1.append(60);
    StringBuffer localStringBuffer3 = localStringBuffer1.append(str2);
    Object localObject = paramJSONArray.opt(1);
    int i;
    JSONObject localJSONObject;
    Iterator localIterator;
    if ((localObject instanceof JSONObject))
    {
      i = 2;
      localJSONObject = (JSONObject)localObject;
      localIterator = localJSONObject.keys();
      if (localIterator.hasNext());
    }
    int j;
    while (true)
    {
      j = paramJSONArray.length();
      if (i < j)
        break label216;
      StringBuffer localStringBuffer4 = localStringBuffer1.append(47);
      StringBuffer localStringBuffer5 = localStringBuffer1.append(62);
      return localStringBuffer1.toString();
      String str3 = localIterator.next().toString();
      XML.noSpace(str3);
      String str4 = localJSONObject.optString(str3);
      if (str4 == null)
        break;
      StringBuffer localStringBuffer6 = localStringBuffer1.append(32);
      String str5 = XML.escape(str3);
      StringBuffer localStringBuffer7 = localStringBuffer1.append(str5);
      StringBuffer localStringBuffer8 = localStringBuffer1.append(61);
      StringBuffer localStringBuffer9 = localStringBuffer1.append(34);
      String str6 = XML.escape(str4);
      StringBuffer localStringBuffer10 = localStringBuffer1.append(str6);
      StringBuffer localStringBuffer11 = localStringBuffer1.append(34);
      break;
      i = 1;
    }
    label216: StringBuffer localStringBuffer12 = localStringBuffer1.append(62);
    label310: label366: 
    while (true)
    {
      localObject = paramJSONArray.get(i);
      i += 1;
      if (localObject != null)
      {
        if (!(localObject instanceof String))
          break label310;
        String str7 = XML.escape(localObject.toString());
        StringBuffer localStringBuffer13 = localStringBuffer1.append(str7);
      }
      while (true)
      {
        if (i < j)
          break label366;
        StringBuffer localStringBuffer14 = localStringBuffer1.append(60);
        StringBuffer localStringBuffer15 = localStringBuffer1.append(47);
        StringBuffer localStringBuffer16 = localStringBuffer1.append(str2);
        StringBuffer localStringBuffer17 = localStringBuffer1.append(62);
        break;
        if ((localObject instanceof JSONObject))
        {
          String str8 = toString((JSONObject)localObject);
          StringBuffer localStringBuffer18 = localStringBuffer1.append(str8);
          continue;
        }
        if (!(localObject instanceof JSONArray))
          continue;
        String str9 = toString((JSONArray)localObject);
        StringBuffer localStringBuffer19 = localStringBuffer1.append(str9);
      }
    }
  }

  public static String toString(JSONObject paramJSONObject)
    throws JSONException
  {
    StringBuffer localStringBuffer1 = new StringBuffer();
    String str1 = paramJSONObject.optString("tagName");
    String str2;
    if (str1 == null)
    {
      str2 = XML.escape(paramJSONObject.toString());
      return str2;
    }
    XML.noSpace(str1);
    str1 = XML.escape(str1);
    StringBuffer localStringBuffer2 = localStringBuffer1.append(60);
    StringBuffer localStringBuffer3 = localStringBuffer1.append(str1);
    Iterator localIterator = paramJSONObject.keys();
    label59: JSONArray localJSONArray;
    if (!localIterator.hasNext())
    {
      localJSONArray = paramJSONObject.optJSONArray("childNodes");
      if (localJSONArray != null)
        break label221;
      StringBuffer localStringBuffer4 = localStringBuffer1.append(47);
      StringBuffer localStringBuffer5 = localStringBuffer1.append(62);
    }
    label221: int j;
    while (true)
    {
      str2 = localStringBuffer1.toString();
      break;
      String str3 = localIterator.next().toString();
      if ((str3.equals("tagName")) || (str3.equals("childNodes")))
        break label59;
      XML.noSpace(str3);
      String str4 = paramJSONObject.optString(str3);
      if (str4 == null)
        break label59;
      StringBuffer localStringBuffer6 = localStringBuffer1.append(32);
      String str5 = XML.escape(str3);
      StringBuffer localStringBuffer7 = localStringBuffer1.append(str5);
      StringBuffer localStringBuffer8 = localStringBuffer1.append(61);
      StringBuffer localStringBuffer9 = localStringBuffer1.append(34);
      String str6 = XML.escape(str4);
      StringBuffer localStringBuffer10 = localStringBuffer1.append(str6);
      StringBuffer localStringBuffer11 = localStringBuffer1.append(34);
      break label59;
      StringBuffer localStringBuffer12 = localStringBuffer1.append(62);
      int i = localJSONArray.length();
      j = 0;
      if (j < i)
        break label280;
      StringBuffer localStringBuffer13 = localStringBuffer1.append(60);
      StringBuffer localStringBuffer14 = localStringBuffer1.append(47);
      StringBuffer localStringBuffer15 = localStringBuffer1.append(str1);
      StringBuffer localStringBuffer16 = localStringBuffer1.append(62);
    }
    label280: Object localObject = localJSONArray.get(j);
    if (localObject != null)
    {
      if (!(localObject instanceof String))
        break label329;
      String str7 = XML.escape(localObject.toString());
      StringBuffer localStringBuffer17 = localStringBuffer1.append(str7);
    }
    while (true)
    {
      j += 1;
      break;
      label329: if ((localObject instanceof JSONObject))
      {
        String str8 = toString((JSONObject)localObject);
        StringBuffer localStringBuffer18 = localStringBuffer1.append(str8);
        continue;
      }
      if (!(localObject instanceof JSONArray))
        continue;
      String str9 = toString((JSONArray)localObject);
      StringBuffer localStringBuffer19 = localStringBuffer1.append(str9);
    }
  }
}

/* Location:           D:\Program Files\eclipse\apktool-r01-3\新浪微博\classes.dex.dex2jar.jar
 * Qualified Name:     sudroid.json.JSONML
 * JD-Core Version:    0.6.0
 */